<?php 
/**
 * 
 * 账号 处理类
 * @author tanzhe
 *
 */
class account {
	private $accountModel;
	private $db;
	private $url;
	
	public function __construct() {
		$this->accountModel = new AccountModel();
		$this->url = new Url();
		//$this->db = new Data();
		/*
		global $trust_server;
		if (!array_key_exists($_SERVER['REMOTE_ADDR'], $trust_server)) {
			echo "fail:auth ".$_SERVER['REMOTE_ADDR'];
			exit;
		}
		*/
	}
	public function cacheFlush(){
		$cache = new Cache();
		$cache->flush();
	}
		
	public function register() { //注册
		$txtUserName = $this->url->get('account');
		$txtPassword = $this->url->get('password');
		$txtEmail = $this->url->get('email');
		$sign = $this->url->get('sign');
		$referer = $this->url->get('referer');
		$code = $this->url->get('code');
		$ret = $this->accountModel->register($txtUserName, $txtPassword, $txtEmail, $sign, $referer, $code);
	
		$callback = $this->url->get('jsonpcallback');
		Json::do_jsonp_encode($callback, $ret);
	}
	
	public function login() { //登录
		$username = $this->url->get('username');
		$password = $this->url->get('password');
		$ret = $this->accountModel->login($username, $password);
	
		$callback = $this->url->get('jsonpcallback');
		Json::do_jsonp_encode($callback, $ret);
	}
}
?>